<?php
/**
 * @version             0.1
 * @package             JImageLib
 * @author 		Daniel Ghilea <danutz@gmail.com>
 * @copyright   Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license             GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );
jimport( 'JImageLib.JImageLib' );



class plgSystemJimagelib extends JPlugin {

	/**
	 * Constructor
	 *
	 * For php4 compatability we must not use the __constructor as a constructor for plugins
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
	 * This causes problems with cross-referencing necessary for the observer design pattern.
	 *
	 * @param object $subject The object to observe
	 * @param object $params  The object that holds the plugin parameters
	 * @since 1.5
	 */
        function plgSystemJimagelib( &$subject, $params )
        {
                parent::__construct( $subject, $params );
        }
	
                
        function onAfterDispatch()
        {
        	
			$file = JPATH_SITE . DS . JImageLib::GREYBOX_JS_PATH . "path.js";
			$fh = fopen($file, 'w');
			$txt = 'var GB_ROOT_DIR = "' .JURI::root() . JImageLib::GREYBOX_JS_PATH . '"; ';
			fwrite($fh, $txt);
			fclose($fh);
			
			$document = &JFactory::getDocument();
			// Add slimbox css and js
			// no longer used since Joomla! has mootools included 
        	//$document->addScript(JURI::root() . JImageLib::SLIMBOX_JS_PATH.'mootools.js');
			$document->addScript(JURI::root() . JImageLib::SLIMBOX_JS_PATH.'slimbox.js');
			$document->addStyleSheet(JURI::root() . JImageLib::SLIMBOX_CSS_PATH.'slimbox.css');
			
			// Add graybox css and js
			$document->addScript(JURI::root() . JImageLib::GREYBOX_JS_PATH .'path.js');
			$document->addScript(JURI::root() . JImageLib::GREYBOX_JS_PATH .'AJS.js');
			$document->addScript(JURI::root() . JImageLib::GREYBOX_JS_PATH .'AJS_fx.js');
			$document->addScript(JURI::root() . JImageLib::GREYBOX_JS_PATH .'gb_scripts.js');
        	$document->addStyleSheet(JURI::root() . JImageLib::GREYBOX_CSS_PATH .'gb_styles.css');
			
        }
}


?>